package com.ruoyi.statisticalCenter.controller;

import java.util.List;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.logistic.domain.PageInfo;
import com.ruoyi.statisticalCenter.domain.vo.ScCashFlowVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.statisticalCenter.domain.ScCashFlow;
import com.ruoyi.statisticalCenter.service.IScCashFlowService;
import com.ruoyi.common.core.controller.BaseController;

/**
 * 现金流水Controller
 *
 * @author pyx
 * @date 2024-02-27
 */
@RestController
@Api(tags = "统计中心-现金流水统计")
@RequestMapping("/sc/cashFlow")
public class ScCashFlowController extends BaseController {
    @Autowired
    private IScCashFlowService scCashFlowService;

    /**
     * 查询现金流水列表
     */
    @PostMapping("/list")
    @ApiOperation("分页查询现金流水列表")
    public R list(@RequestBody ScCashFlowVo scCashFlowVo) {
        List<ScCashFlow> list = scCashFlowService.selectScCashFlowList(scCashFlowVo);
        if (list == null || list.size() == 0){
            return R.fail("暂无数据");
        }else {
            return R.ok(PageInfo.info(list));
        }
    }


    @PostMapping("/add")
    @ApiOperation("新增现金流水")
    public R addSave(@RequestBody ScCashFlow scCashFlow) {
        return scCashFlowService.insertScCashFlow(scCashFlow);
    }


    /**
     * 修改现金流水
     */
    @PostMapping("/edit")
    @ApiOperation("修改现金流水")
    public R editSave(@RequestBody ScCashFlow scCashFlow) {
        return scCashFlowService.updateScCashFlow(scCashFlow);
    }

    /**
     * 删除现金流水
     */
    @PostMapping("/remove")
    @ApiOperation("删除现金流水")
    public R remove(String ids) {
        return scCashFlowService.deleteScCashFlowByIds(ids);
    }
}
